import requests


def send_verifications(phone, code):
    """接口作用于发送语音验证码 """
    key = 'd28090cebf4ac9aeea7cb984651580b9'
    url = 'http://op.juhe.cn/yuntongxun/voice?key={}&valicode={}&to={}&playtimes=3'.format(key, code, phone)

    # 取消状态判断，直接返回成功
    try:
        requests.get(url)
        # cont = r.content.decode()
        # cont_json = loads(cont)
        # print(cont_json)
        # if cont_json['error_code"'] == 0:
        #     return True
        return True
    except:
        return False


if __name__ == '__main__':
    result = send_verifications('18395552238', '123456')
    print(result)
